package com.seirsoft.framework.payload;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

public class PayloadTableCollection
{
    // Fields
    protected Hashtable<String, PayloadTable> m_tableDictionary;
    protected List<PayloadTable> m_tableList;
    
    public PayloadTableCollection()
    {
        m_tableDictionary = new Hashtable<String, PayloadTable>();
        m_tableList = new ArrayList<PayloadTable>();   	
    }
    
    public void addTable(PayloadTable table)
    {
    	if(! m_tableDictionary.containsKey(table.getName()))
    	{
    		m_tableDictionary.put(table.getName(), table);
    		m_tableList.add(table);
    	}
    }
    
    public void clear()
    {
    	m_tableList.clear();
    	m_tableDictionary.clear();
    }
    
    public int getCount()
    {
    	return this.m_tableList.size();
    }

    public PayloadTable getTable(int index)
    {
    	return this.m_tableList.get(index);
    }
    
    public PayloadTable getTable(String strTableName)
    {
    	return this.m_tableDictionary.get(strTableName);
    }
}
